package edu.tongji.structureplayer.core.test
{
    import edu.tongji.structureplayer.core.math.Determinant;
    
    import flexunit.framework.Assert;
    
    public class TestDeterminant
    {		
        [Before]
        public function setUp():void
        {
        }
        
        [After]
        public function tearDown():void
        {
        }
        
        [BeforeClass]
        public static function setUpBeforeClass():void
        {
        }
        
        [AfterClass]
        public static function tearDownAfterClass():void
        {
        }
        
        [Test]
        public function testCopy():void
        {
            var cols:uint = 2;
            var rows:uint = 3;
            var det:Determinant = new Determinant(rows,cols);
            for (var i:uint=0; i<rows; i++)
            {
                for (var j:uint=0; j<cols; j++)
                    det.data[i][j] = Math.random();
            }
            det.debugPrint();
            trace();
            det.copy().debugPrint();
        }
        
        [Test]
        public function testDeterminant():void
        {
            var cols:uint = 2;
            var rows:uint = 3;
            var det:Determinant = new Determinant(rows,cols);
            for (var i:uint=0; i<rows; i++)
            {
                for (var j:uint=0; j<cols; j++)
                    det.data[i][j] = Math.random();
            }
            det.debugPrint();
        }
        
        [Test]
        public function testMultiply():void
        {
            var cols1:uint = 3;
            var rows1:uint = 2;
            var det1:Determinant = new Determinant(rows1,cols1);
            det1.data[0][0] = 1;
            det1.data[0][1] = 2;
            det1.data[0][2] = 3;
            det1.data[1][0] = 1;
            det1.data[1][1] = 3;
            det1.data[1][2] = 5;
            
            var cols2:uint = 1;
            var rows2:uint = 3;
            var det2:Determinant = new Determinant(rows2,cols2);
            det2.data[0][0] = 2;
            det2.data[1][0] = 4;
            det2.data[2][0] = 6;
            
            det1.multiply(det2).debugPrint();
        }
        
        [Test]
        public function testSpilt():void
        {
            var cols:uint = 4;
            var rows:uint = 6;
            var det:Determinant = new Determinant(rows,cols);
            for (var i:uint=0; i<rows; i++)
            {
                for (var j:uint=0; j<cols; j++)
                    det.data[i][j] = Math.random();
            }
            det.debugPrint();
            trace();
            var result:Array = det.spilt(3, 2);
            for (var ii:uint=0; ii<3; ii++)
            {
                for (var jj:uint=0; jj<2; jj++)
                {
                    result[ii][jj].debugPrint();
                    trace();
                }
            }
        }
    }
}